//
//  RS4ViewController.m
//  SmartRoadShow
//
//  Created by simon on 10-9-17.
//  Copyright 2010 simonwang142232@gmail.com. All rights reserved.
//

#import "RS4ViewController.h"
#import "Dealer.h"
#import "Level2TableViewCell.h"
#import <QuartzCore/QuartzCore.h>
#import "SendHttpRequest.h"
#import "MyDataSource.h"
#import "CallUtil.h"

#define kSection_1_height 77.3
#define kSection_2_height 83
#define kSection_3_height 85

@interface RS4ViewController() 

-(void) moblieWeb;

@end


@implementation RS4ViewController






- (void)viewDidLoad 
{
	[super viewDidLoad];
	self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480-44-80)];
	self.view.layer.contents = (id)[UIImage imageNamed:@"contactUs.png"].CGImage;
	
	UILabel *callLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, 13, 300, 25)];
	[callLabel setText:@"欢迎您拨打smart服务热线：400-811-0000"];
	[callLabel setBackgroundColor:[UIColor clearColor]];
	[callLabel setFont:[UIFont boldSystemFontOfSize:12.5]];
	[self.view addSubview:callLabel];
	[callLabel release];
	
	UIControl *control1 = [[UIControl alloc] initWithFrame:CGRectMake(260, 5, 70, 45)];
	[control1 addTarget:self action:@selector(callHotline) forControlEvents:UIControlEventTouchUpInside];
	[self.view addSubview:control1];
	[control1 release];
	
	UIButton *callButton = [UIButton buttonWithType:UIButtonTypeCustom];
	[callButton addTarget:self action:@selector(callHotline) forControlEvents:UIControlEventTouchUpInside];
	[callButton setFrame:CGRectMake(276, 16, 17, 17)];
	[callButton setImage:[UIImage imageNamed:@"call.png"] forState:UIControlStateNormal];
	[self.view addSubview:callButton];
	
	
	UILabel *dealerLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, 45, 100, 25)];
	[dealerLabel setText:@"经销商查询："];
	[dealerLabel setFont:[UIFont boldSystemFontOfSize:12.5]];
	[dealerLabel setBackgroundColor:[UIColor clearColor]];
	[self.view addSubview:dealerLabel];
	[dealerLabel release];
	
	//主要部分
	m_scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 70, 320, 275)];
	[m_scrollView setBackgroundColor:[UIColor clearColor]];
	[m_scrollView setShowsVerticalScrollIndicator:NO];
	[self.view addSubview:m_scrollView];
	[m_scrollView release];
	
	northButton = [UIButton buttonWithType:UIButtonTypeCustom];
	[northButton addTarget:self action:@selector(selectDealer:) forControlEvents:UIControlEventTouchUpInside];
	[northButton setTag:3001];
	[northButton setFrame:CGRectMake(25, 0, 268, 25)];
	[northButton.titleLabel setFont:[UIFont boldSystemFontOfSize:14]];
	[northButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
	[northButton setBackgroundImage:[UIImage imageNamed:@"dealerUnselected.png"] forState:UIControlStateNormal];
	[northButton setBackgroundImage:[UIImage imageNamed:@"dealerUnselected.png"] forState:UIControlStateHighlighted];
	[northButton setTitle:@"    华北地区" forState:UIControlStateNormal];
	[northButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
	[northButton.titleLabel setTextAlignment:UITextAlignmentLeft];
	[m_scrollView addSubview:northButton];
	
	eastButton = [UIButton buttonWithType:UIButtonTypeCustom];
	[eastButton addTarget:self action:@selector(selectDealer:) forControlEvents:UIControlEventTouchUpInside];
	[eastButton setTag:3002];
	[eastButton setFrame:CGRectMake(25, 28, 268, 25)];
	[eastButton.titleLabel setFont:[UIFont boldSystemFontOfSize:14]];
	[eastButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
	[eastButton setBackgroundImage:[UIImage imageNamed:@"dealerUnselected.png"] forState:UIControlStateNormal];
	[eastButton setBackgroundImage:[UIImage imageNamed:@"dealerUnselected.png"] forState:UIControlStateHighlighted];
	[eastButton setTitle:@"    华东地区" forState:UIControlStateNormal];
	[eastButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
	[eastButton.titleLabel setTextAlignment:UITextAlignmentLeft];
	[m_scrollView addSubview:eastButton];
	
	southButton = [UIButton buttonWithType:UIButtonTypeCustom];
	[southButton addTarget:self action:@selector(selectDealer:) forControlEvents:UIControlEventTouchUpInside];
	[southButton setTag:3003];
	[southButton setFrame:CGRectMake(25, 56, 268, 25)];
	[southButton.titleLabel setFont:[UIFont boldSystemFontOfSize:14]];
	[southButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
	[southButton setBackgroundImage:[UIImage imageNamed:@"dealerUnselected.png"] forState:UIControlStateNormal];
	[southButton setBackgroundImage:[UIImage imageNamed:@"dealerUnselected.png"] forState:UIControlStateHighlighted];
	[southButton setTitle:@"    华南地区" forState:UIControlStateNormal];
	[southButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
	[southButton.titleLabel setTextAlignment:UITextAlignmentLeft];
	[m_scrollView addSubview:southButton];
	
	buttonArray = [[NSArray alloc] initWithObjects:northButton,eastButton,southButton,nil];
	
	selected = NO;
	
	m_tableView = [[UITableView alloc] init];
	[m_tableView setDelegate:self];
	[m_tableView setDataSource:self];
	[m_tableView setBackgroundColor:[UIColor colorWithRed:0.97 green:0.945 blue:0.81 alpha:1]];
	[m_tableView setScrollEnabled:NO];
	
	[m_tableView setSeparatorColor:[UIColor colorWithRed:0.702 green:0.682 blue:0.498 alpha:1]];
	m_tableView.layer.borderWidth = 2.5;
	m_tableView.layer.borderColor = [[UIColor colorWithRed:0.97 green:0.945 blue:0.81 alpha:1] CGColor];
	
	
	nearestButton = [UIButton buttonWithType:UIButtonTypeCustom];
	[nearestButton setBackgroundImage:[UIImage imageNamed:@"nearest.png"] forState:UIControlStateNormal];
	[nearestButton setBackgroundColor:[UIColor clearColor]];
	[nearestButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
	nearestButton.frame = CGRectMake(60, 190, 200, 30);
	nearestButton.layer.cornerRadius = 3;
	nearestButton.layer.masksToBounds =YES;
	nearestButton.titleLabel.font = [UIFont boldSystemFontOfSize:12.5];
	[nearestButton setTitle:@"查看离你最近的经销商" forState:UIControlStateNormal];
	[nearestButton addTarget:self action:@selector(nearestDealer) forControlEvents:UIControlEventTouchUpInside];
	[m_scrollView addSubview:nearestButton];
	
	separator = [[UIView alloc] initWithFrame:CGRectMake(5, 228, 310, 1.2)];
	separator.backgroundColor = [UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1];
	[m_scrollView addSubview:separator];
	[separator release];
	
	webLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, 225, 268, 50)];
	[webLabel setNumberOfLines:2];
	[webLabel setFont:[UIFont boldSystemFontOfSize:13]];
	[webLabel setBackgroundColor:[UIColor clearColor]];
	[webLabel setText:@"欢迎您访问smart社区手机版：\nhttp://www.the-smart-class.mobi/"];
	[m_scrollView addSubview:webLabel];
	[webLabel release];
	
	
	webButton = [UIButton buttonWithType:UIButtonTypeCustom];
	[webButton addTarget:self action:@selector(moblieWeb) forControlEvents:UIControlEventTouchUpInside];
	[webButton setFrame:CGRectMake(25, 225, 268, 50)];
	[webButton setBackgroundColor:[UIColor clearColor]];
	[m_scrollView addSubview:webButton];
	
	
	NSError *error;
	NSString *path = [[NSBundle mainBundle] pathForResource:@"Dealer" ofType:@"xml"];
	NSString *xmlStr = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
	dealerArr = [[MyDataSource dealerGetDataFromXMLDocument:xmlStr] retain];
	
	currentArray = [[NSArray alloc] init];
	
	array1 = [[NSMutableArray alloc] init];
	array2 = [[NSMutableArray alloc] init];
	array3 = [[NSMutableArray alloc] init];
	
	int count = [dealerArr count];
	for(int i=0; i<count; i++)
	{
		Dealer *dealer1 = [dealerArr objectAtIndex:i];
		
		if([dealer1._area isEqualToString:@"华北"])
		{
			[array1 addObject:dealer1];
		}
		else if([dealer1._area isEqualToString:@"华东"])
		{
			[array2 addObject:dealer1];
		}
		else {
			[array3 addObject:dealer1];
		}
	}
	
	mapURL = [[NSString alloc] init];
	phoneNumber = [[NSString alloc] init];
	locationManager = [[CLLocationManager alloc] init];
	[locationManager setDelegate:self];
}

- (void)selectDealer:(UIButton *)button{
	
	CGFloat changedHeight = 0.0;
    
	[m_scrollView setContentSize:CGSizeMake(320, 275)];
	[eastButton setFrame:CGRectMake(25, 28, 268, 25)];
	[southButton setFrame:CGRectMake(25, 56, 268, 25)];
	[nearestButton setFrame:CGRectMake(60, 190, 200, 30)];
	[separator setFrame:CGRectMake(5, 228, 310, 1.2)];
	[webLabel setFrame:CGRectMake(25, 225, 268, 50)];
	[webButton setFrame:CGRectMake(25, 225 , 268, 50)];
    
	for (UIButton *buto in buttonArray){
		[buto setBackgroundImage:[UIImage imageNamed:@"dealerUnselected.png"] forState:UIControlStateNormal];
		[buto setBackgroundImage:[UIImage imageNamed:@"dealerUnselected.png"] forState:UIControlStateHighlighted];
	}
	
	if (selected) {
		[m_tableView removeFromSuperview];
		if (preButtonTag != button.tag) {
			
			switch (button.tag) {
				case 3001:{
					currentArea = 1;
					currentArray = array1;
					[m_scrollView addSubview:m_tableView];
					
					changedHeight = kSection_1_height * [currentArray count];
					[m_tableView setFrame:CGRectMake(25, 25, 268, changedHeight)];
					[m_scrollView setContentSize:CGSizeMake(320, 275 + changedHeight)];
					[eastButton setFrame:CGRectMake(25, 28 + changedHeight, 268, 25)];
					[southButton setFrame:CGRectMake(25, 56 + changedHeight, 268, 25)];
					[nearestButton setFrame:CGRectMake(60, 190 + changedHeight, 200, 30)];
					[separator setFrame:CGRectMake(5, 228 + changedHeight, 310, 1.2)];
					[webLabel setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];
					[webButton setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];
					
					break;
				}
				case 3002:{
					currentArea = 2;
					currentArray = array2;
					[m_scrollView addSubview:m_tableView];
					
					changedHeight = kSection_2_height * [currentArray count];
					[m_tableView setFrame:CGRectMake(25, 53, 268, changedHeight)];
					[m_scrollView setContentSize:CGSizeMake(320, 275 + changedHeight)];
					[southButton setFrame:CGRectMake(25, 56 + changedHeight, 268, 25)];
					[nearestButton setFrame:CGRectMake(60, 190 + changedHeight, 200, 30)];
					[separator setFrame:CGRectMake(5, 228 + changedHeight, 310, 1.2)];
					[webLabel setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];
					[webButton setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];					
					
					break;
				}
				case 3003:{
					currentArea = 3;
					
					currentArray = array3;
					[m_scrollView addSubview:m_tableView];
					
					changedHeight = kSection_3_height * [currentArray count];
					[m_tableView setFrame:CGRectMake(25, 81, 268, changedHeight)];	
					[m_scrollView setContentSize:CGSizeMake(320, 275 + changedHeight)];
					[nearestButton setFrame:CGRectMake(60, 190 + changedHeight, 200, 30)];
					[webLabel setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];
					[separator setFrame:CGRectMake(5, 228 + changedHeight, 310, 1.2)];
					[webButton setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];			
					break;
				}
				default:
					break;
			}
			
			[button setBackgroundImage:[UIImage imageNamed:@"dealerSelected.png"] forState:UIControlStateNormal];
			[button setBackgroundImage:[UIImage imageNamed:@"dealerSelected.png"] forState:UIControlStateHighlighted];
			[m_tableView reloadData];
			[m_tableView  scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 
                                      inSection:0]
							    atScrollPosition:UITableViewScrollPositionTop
                                       animated:NO];
			
		}
		
		selected = NO;
	}
	else {
		[button setBackgroundImage:[UIImage imageNamed:@"dealerSelected.png"] forState:UIControlStateNormal];
		[button setBackgroundImage:[UIImage imageNamed:@"dealerSelected.png"] forState:UIControlStateHighlighted];
		selected = YES;
		switch (button.tag) {
			case 3001:{
				currentArea = 1;
				currentArray = array1;
				[m_scrollView addSubview:m_tableView];
				
				changedHeight = kSection_1_height * [currentArray count];
				[m_tableView setFrame:CGRectMake(25, 25, 268, changedHeight)];
				[m_scrollView setContentSize:CGSizeMake(320, 275 + changedHeight)];
				[eastButton setFrame:CGRectMake(25, 28 + changedHeight, 268, 25)];
				[southButton setFrame:CGRectMake(25, 56 + changedHeight, 268, 25)];
				[nearestButton setFrame:CGRectMake(60, 190 + changedHeight, 200, 30)];
				[separator setFrame:CGRectMake(5, 228 + changedHeight, 310, 1.2)];
				[webLabel setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];
				[webButton setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];
				
				break;
			}
			case 3002:{
				currentArea = 2;
				currentArray = array2;
				[m_scrollView addSubview:m_tableView];
				
				changedHeight = kSection_2_height * [currentArray count];
				[m_tableView setFrame:CGRectMake(25, 53, 268, changedHeight)];
				[m_scrollView setContentSize:CGSizeMake(320, 275 + changedHeight)];
				[southButton setFrame:CGRectMake(25, 56 + changedHeight, 268, 25)];
				[nearestButton setFrame:CGRectMake(60, 190 + changedHeight, 200, 30)];
				[webLabel setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];
				[separator setFrame:CGRectMake(5, 228 + changedHeight, 310, 1.2)];
				[webButton setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];					
				
				break;
			}
			case 3003:{
				currentArea = 3;
				
				currentArray = array3;
				[m_scrollView addSubview:m_tableView];
				
				changedHeight = kSection_3_height * [currentArray count];
				[m_tableView setFrame:CGRectMake(25, 81, 268, changedHeight)];	
				[m_scrollView setContentSize:CGSizeMake(320, 275 + changedHeight)];
				[nearestButton setFrame:CGRectMake(60, 190 + changedHeight, 200, 30)];
				[webLabel setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];
				[separator setFrame:CGRectMake(5, 228 + changedHeight, 310, 1.2)];
				[webButton setFrame:CGRectMake(25, 225 + changedHeight, 268, 50)];			
				break;
			}
			default:
				break;
		}
		[m_tableView reloadData];
		[m_tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0
															   inSection:0]
						   atScrollPosition:UITableViewScrollPositionTop
								   animated:NO];
		
		
	}
	
	preButtonTag = button.tag;
}

-(void)callHotline{
	CallUtil *call = [CallUtil getInstance];
	[call callPhoneNumber:@"400-811-0000"];
}


- (void)locationManager: (CLLocationManager *)manager didFailWithError: (NSError *)error {
	
    NSString *errorString;
    [manager stopUpdatingLocation];
    NSLog(@"Error: %@",[error localizedDescription]);
    switch([error code]) {
        case kCLErrorDenied:
        case kCLErrorLocationUnknown:
        default:
            errorString = @"建议开启定位服务（设置>通用>还原>还原位置警告）";
            break;
	}
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"定位服务不可用" message:errorString delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
	[alert show];
	[alert release];
}


- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation
		   fromLocation:(CLLocation *)oldLocation
{
	if (firstAlert) {
		firstAlert = NO;
		UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"您将离开该应用前往地图服务，是否继续？"
														message:nil
													   delegate:self
											  cancelButtonTitle:@"确定"
											  otherButtonTitles:@"取消",nil];
		[alert setTag:601];
		[alert show];
		[alert release];
		
	}
}

-(void) nearestDealer

{		
	firstAlert = YES;
	
	[locationManager startUpdatingLocation];

	
}


- (void)moblieWeb{
	
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"您将退出此应用，前去访问smart社区手机版网站。"
													message:nil
												   delegate:self
										  cancelButtonTitle:@"确定"
										  otherButtonTitles:@"取消",nil];
	[alert setTag:401];
	[alert show];
	[alert release];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
	
	if (buttonIndex == 0) {
		switch (alertView.tag) {
			case 401:
			{
				if (buttonIndex == 0) {
					NSURL *url = [NSURL URLWithString:@"http://www.the-smart-class.mobi/"];
					[[UIApplication sharedApplication] openURL:url];
				}
				break;
			}
			case 402:
			{
				NSString *strUrl = mapURL;
				strUrl = [strUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
				NSURL *url = [NSURL URLWithString:strUrl];
				[[UIApplication sharedApplication] openURL:url];
				
				break;
			}
			case 601:
			{
				CLLocation *location = [locationManager location];		
				CGFloat m_latitude = location.coordinate.latitude;
				CGFloat m_longitude = location.coordinate.longitude;
				CGFloat minDistance = 1000.0;
				int minIndex = 0;
				for (int i = 0; i < [dealerArr count]; i++) 
				{
					CGFloat la = [[dealerArr objectAtIndex:i] _latitude];
					CGFloat lo = [[dealerArr objectAtIndex:i] _longitude];
					CGFloat distance = (la - m_latitude) * (la - m_latitude) + (lo - m_longitude) * (lo - m_longitude);
					if (minDistance > distance) {
						minDistance = distance;
						minIndex = i;
					}
				}				
				NSString *strUrl = [[dealerArr objectAtIndex:minIndex] _googleurl];
				strUrl = [strUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
				NSURL *url = [NSURL URLWithString:strUrl];
				[[UIApplication sharedApplication] openURL:url];
				[locationManager stopUpdatingHeading];
				break;
			}
			default:
				break;
		}
	}
}



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}


#pragma mark UITableViewDelegate,dataSource
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section
{
	return [currentArray count];
	
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	
	Level2TableViewCell *cell = nil;
	if(!cell)
	{
		cell = [[Level2TableViewCell alloc] init];
		//		cell = [[[Level2TableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellLevel2] autorelease];
		[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
		
	}	
	Dealer *dealer = [currentArray objectAtIndex:indexPath.row];
	[cell setDelegate:self];
	cell.index = indexPath.row;
	[cell setCompanyLabelText:[NSString stringWithFormat:@"%@(%@)" ,dealer._name,dealer._show]];
	[cell setPhoneLabelText:[NSString stringWithFormat:@"%@", dealer._phone]];
	[cell setAddressLabelText:[NSString stringWithFormat:@"%@",dealer._address]];
	return cell;
	
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
	Dealer *dealer = [currentArray objectAtIndex:indexPath.row];
	UIFont *font = [UIFont systemFontOfSize:12];  
	CGSize size1 = [[NSString stringWithFormat:@"%@(%@)",dealer._name,dealer._show] sizeWithFont:font constrainedToSize:CGSizeMake(170, 1000) lineBreakMode:UILineBreakModeWordWrap];  
	CGSize size2 = [dealer._address sizeWithFont:font constrainedToSize:CGSizeMake(190, 1000) lineBreakMode:UILineBreakModeWordWrap]; 
	return size1.height + size2.height + 30;
}

#pragma mark Level2TableViewCell Delegate

-(void) showMapButtonSelected:(NSInteger) index{
	switch (currentArea) {
		case 1:
			mapURL = [[array1 objectAtIndex:index] _googleurl];
			break;
		case 2:
			mapURL = [[array2 objectAtIndex:index] _googleurl];
			break;
        case 3:
			mapURL = [[array3 objectAtIndex:index] _googleurl];
			break;
			
		default:
			break;
	}
	NSLog(@"map url : %@",mapURL);
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"您将离开该应用前往地图服务，是否继续？"
													message:nil
												   delegate:self
										  cancelButtonTitle:@"确定"
										  otherButtonTitles:@"取消",nil];
	[alert setTag:402];
	[alert show];
	[alert release];
}


-(void) telephoneButtonSelected:(NSInteger) index{
	switch (currentArea) {
		case 1:
			phoneNumber = [[array1 objectAtIndex:index] _phone];
			break;
		case 2:
			phoneNumber = [[array2 objectAtIndex:index] _phone];
			break;
        case 3:
			phoneNumber = [[array3 objectAtIndex:index] _phone];
			break;
			
		default:
			break;
	}
	
	CallUtil *call = [CallUtil getInstance];
	[call callPhoneNumber:phoneNumber];	
	
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}


- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
	webLabel = nil;
	webButton = nil;
	nearestButton = nil;
	m_scrollView = nil;
	m_tableView = nil;
	eastButton = nil;
	southButton = nil;
	northButton = nil;
	
}


- (void)dealloc
{
	[webLabel release];
	[webButton release];
	[nearestButton release];
	[m_tableView release];
	[m_scrollView release];
	[eastButton release];
	[northButton release];
	[southButton release];
	[dealerArr release];
	
	[array1 release];
	[array2 release];
	[array3 release];
	
	[buttonArray release];
	[mapURL release];
	[phoneNumber release];
	
	[locationManager release];
	
    [super dealloc];
}


@end
